import http from '@/lib/http'

export interface OrderPayload {
  id?: number
  orderNo?: string
  totalPrice?: number
  userId?: number
  linkUser?: string
  linkPhone?: string
  linkAddress?: string
  state?: string
}

export function listOrders(params?: any) {
  return http.get('/tOrder', { params })
}

export function getOrder(id: string | number) {
  return http.get(`/tOrder/${id}`)
}

export function createOrder(data: OrderPayload) {
  return http.post('/tOrder', data)
}

export function updateOrder(data: OrderPayload) {
  return http.put('/tOrder', data)
}

export function deleteOrders(idList: (number|string)[]) {
  // Directly construct URL with comma-separated string to avoid axios automatic array serialization
  const ids = idList.join(',');
  return http.delete(`/tOrder?idList=${ids}`)
}


